const {basename, dirname, extname} = require(
    'path'
)

const filePath = '/usr/local/bin/no.txt'

console.log(dirname(filePath))
console.log(basename(filePath))
console.log(extname(filePath))

/*
输出结果：
/usr/local/bin
no.txt
.txt
 */